package todomanager.View;

/**
 * 
 * @author Shirin
 * @author Jonas Birgersson
 */
import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import todomanager.MODEL.TodoManagerModel;

public class ReminderView extends JFrame {
	
	private JPanel panel;
	private JList reminderList;
	private TodoManagerModel todoModel;
	private JScrollPane reminderScroll;
	
	public ReminderView(TodoManagerModel todoModel) {
		this.todoModel = todoModel;
		init();
	}
	
	public void init(){
		
		this.setTitle("Pending tasks");
		this.setSize(200,400);
		panel = new JPanel();
		panel.setLayout(new BorderLayout());
		
		reminderList = new JList(todoModel.getPendingTasks(3).toArray());
		reminderScroll = new JScrollPane(reminderList);

		panel.add(reminderScroll);
		this.add(panel);
		
		
	}
}

//	public ReminderView() {
//		try {
//			Rframe();
//			dateShow();
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//	}
//
//	private JPanel topPanel;
//	private JList listbox;
//
//	private void Rframe() throws Exception {
//
//		this.setSize(new Dimension(400, 300));
//		this.setLayout(new BorderLayout());
//		//this.setDefaultCloseOperation(EXIT_ON_CLOSE);
//		this.setBackground(Color.BLACK);	
//		this.setTitle("Reminder");
//
//		// Create a panel to hold all other components
//		topPanel = new JPanel();
//		topPanel.setLayout(new BorderLayout());
//		getContentPane().add(topPanel);
//
//	}
//
//	/*
//	 * In this class, we get the system date first and compare it with the saved
//	 * date in order to find the dates for showing in Reminder pop up
//	 */
//
//	private CompareDate compareTwoDates;
//
//	public void dateShow() throws FileNotFoundException, IOException,
//			ParseException {
//
//		/*
//		 * Get the stored date
//		 */
//		// ---------------- array for user Date --------------------
//		ArrayList<String> comparedDate = new ArrayList();
//		int J;
//
//		ITodoImporter read = new TodoXMLReader(new BufferedReader(
//				new FileReader("database.xml")));
//
//		ArrayList taskList = read.importDate();
//		//System.out.println("Your date Array List is: " + taskList);
//		Object dateArray[] = taskList.toArray();
//		int ex = dateArray.length;
//		//System.out.println(ex);
//		for (int i = 1; i < ex; i++) {// first For
//			String m = dateArray[i].toString();
//			StringTokenizer st = new StringTokenizer(m, ",");
//			for (int j = 0; j < 3; j++) { // second For
//				while (st.hasMoreElements()) {
//					String token = st.nextToken();
//					// System.out.println(token);
//					compareTwoDates = new CompareDate(token);
//					J = compareTwoDates.compareTwoDates(token);
//					// System.out.println("J is:" + J);
//					if(J==0)
//					comparedDate.add(token);
//				}
//			}// end second For
//		}// end first For
//		
//		//For our example I need this, otherwise ignore this
//		comparedDate.add(0,"yyyy-mm-dd");
////		System.out.println("Your date Array List is: " + comparedDate);
//		
//		// compare main list with date list to show in JList
//		ITodoImporter readMainList = new TodoXMLReader(new BufferedReader(
//				new FileReader("database.xml")));
//
//		ArrayList mainList = readMainList.importList();
//	//	System.out.println("Your date Array List is: " + mainList);
//		for(int d=0;d<comparedDate.size();d++){
//			for(int m=0;m<mainList.size();m++){
//				String date=comparedDate.get(d);
//
//				int index=mainList.indexOf(date);
//				mainList.remove(index);
//				mainList.remove(index-1);
//				break;
//			}
//		}
//		// Create a new listbox control
//		listbox = new JList(mainList.toArray());
//		topPanel.add(listbox, BorderLayout.CENTER);
//
//	}
//}
